﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace XNAGame_Lab1
{
    public class MapWithCell : VisibleGame
    {
        private int _nRow;

        public int nRow
        {
            get { return _nRow; }
            set { _nRow = value; }
        }
        private int _nCol;

        public int nCol
        {
            get { return _nCol; }
            set { _nCol = value; }
        }
        private Cell[,] _cell;

        public Cell[,] Cell
        {
            get { return _cell; }
            set { _cell = value; }
        }
        private float _Scale = 1.0f;

        public float Scale
        {
            get { return _Scale; }
            set { _Scale = value; }
        }
        private Vector2 _UnknowVar;

        public Vector2 UnknowVar
        {
            get { return _UnknowVar; }
            set { _UnknowVar = value; }
        }
        public int CELL_WIDTH = 66;
        public int CELL_HEIGHT = 72;
        public MapWithCell(ContentManager content, string[] strCellTextures, int nCellType,
            int nrows, int ncols, int[,] _cell, Vector2 topleft, Vector2 size)
        {
            CELL_WIDTH = (int)size.X;
            CELL_HEIGHT =(int) size.Y;
            _TopLeft = topleft;
            Size = size;
            Sprites = new List<MySprites2D>();
            nSprites = 0;
            nCol = ncols;
            nRow = nrows;
            Cell = new Cell[nRow, nCol];
            for (int i = 0; i < nRow; i++)
                for (int j = 0; j < nCol; j++)
                    Cell[i, j] = new Cell(content, strCellTextures[_cell[i, j]], new Vector2(i * CELL_WIDTH +100, j * CELL_HEIGHT+160),
                        new Vector2(CELL_WIDTH, CELL_HEIGHT));


        }
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < nRow; i++)
                for (int j = 0; j < nCol; j++)
                    Cell[i, j].Draw(gameTime,spriteBatch);
            base.Draw(gameTime, spriteBatch);
        }
    }
}
